package demo1.controller;

import demo1.bean.Student;
import demo1.service.Impl.StudentServiceImpl;
import demo1.service.StudentService;
import org.junit.jupiter.api.Test;

import java.util.List;

/**
 * @author huagui
 * @date 2021年03月29日 9:19
 */
public class StudentController {
    private StudentService service = new StudentServiceImpl();
    @Test
    public void selectAll(){
        List<Student> list = service.selectAll();
        for (Student stu :
                list) {
            System.out.println(stu);
        }
    }
    @Test
    public void selectById(){
        Student student = service.selectById(2);
        System.out.println(student);
    }
    @Test
    public  void insert(){
        Student stu = new Student(5, "二狗子", 26);
        int insert = service.insert(stu);
        if(insert==1){
            System.out.println("插入成功");
        }else{
            System.out.println("插入失败");
        }
    }
    @Test
    public void update(){
        Student stu = new Student(5, "狗蛋", 25);
        int update = service.update(stu);
        if (update==1){
            System.out.println("更新成功");
        }else{
            System.out.println("更新失败");
        }
    }
    @Test
    public void delete(){
        int delete = service.delete(5);
       if (delete==1){
           System.out.println("删除成功");
       }else{
           System.out.println("删除失败");
       }
    }
}
